<?php

class Materials_Model_Label_Observer_CodeGenerator extends Workset_Model_Observer_Abstract {

    function beforeSave(Workset_Model_Subject_Interface $label, $data = null) {
        $name = $label->getName();

        $name = preg_replace("/[\s]+/", " ", trim($name));
        $name = mb_convert_case($name, MB_CASE_LOWER);
        $name = md5($name);

        $label->setCode($name);

    }

}